package com.solutec.tag15aufgabe;

import java.util.Arrays;

public class PersonenSortieren {

	public static void main(String[] args) {
		System.out.println("---- Strings: ----------");
		String[] strArr = { "ddd", "aaa", "mmm" };
		Arrays.sort(strArr);
		String arrAlsText = Arrays.toString(strArr);
		System.out.println( arrAlsText ); 

		
		Person[] arr = {
			new Person("Peter", "Wolf", 1990),	
			new Person("Paul", "Hase", 2001),	
			new Person("Paul", "Hase", 1950),	
			new Person("Anton", "Wolf", 1988),	
		};
		
		print(arr);
		
		Arrays.sort(arr);
		
		print(arr);
		
		System.out.println("------------ absteigen sortieren --------------------");

		java.util.Comparator cmp = new PersonenComparatorReverse();
		Arrays.sort(arr, cmp);	
		
		print(arr);
		
		System.out.println("------ Sort nach: Geburtsjahr/Nachname/Vorname");
		
		cmp = new PersonenComparatorGeburtsjahrNachnameVorname();
		Arrays.sort(arr, cmp);
		
		print(arr);

	} //end of main
	
	static void print(Person[] arr) {
		System.out.println("---------------------------------");
		
		for(Person p : arr) {
			System.out.println(p);
		}
	}

}
